package com.dd.seckill.cluster.controller;

import com.dd.seckill.cluster.pojo.req.SeckillReq;
import com.dd.seckill.cluster.pojo.response.ApiResponse;
import com.dd.seckill.cluster.service.internal.impl.SeckillServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 执行秒杀操作的控制器
 * </p>
 *
 * @author liuxianmeng
 * @since 2025-09-06
 */
@Slf4j
@RestController
@RequestMapping("/seckill")
@RequiredArgsConstructor
@Api(tags = "秒杀控制器")
public class SeckillController {

    private final SeckillServiceImpl seckillServiceImpl;

    @ApiOperation("消费商品")
    @PostMapping("/consume")
    public ApiResponse<Void> consume(@ApiParam("秒杀请求") @RequestBody SeckillReq req){
        //log.info("C SeckillController M consume() req = {}", req);
        seckillServiceImpl.seckillV2(req);
        return ApiResponse.success();
    }
}
